<!--
    page description : 근태관리 - 관리자 - 사원관리 화면 - 사원등록/수정 (pop_up)
    author      : Yang D
    date        : 2009-02-04
    file name   : holidays_add_p.jsp
-->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<s:head theme="ajax" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="/inc/css/common.css" />
	<link rel="stylesheet" type="text/css" href="/inc/css/dhtmlxcalendar.css" />

	<script type="text/javascript" src="inc/js/common.js"></script>
	<script type="text/javascript" src="/js/common.js"></script>
	<script type="text/javascript" src="/js/dhtmlXCommon.js"></script>
	<script type="text/javascript" src="/js/dhtmlxcalendar.js"></script>
	
	<title>휴일등록 -등록/수정-</title>
	<!-- // --------------------J A V A S C R I P T-START-------------------- // -->
	<script type="text/javascript" language="javascript">
	/////////////////////달력////////////////////////////////////////////////
		function doOnLoad()
		{
			// 달력
			cal1 = new dhtmlxCalendarObject('date', false, {isYearEditable: true});
			cal1.setYearsRange(2000, 2050);
			cal1.setPosition(20,-82);
			cal1.draw();
			cal1.setOnClickHandler(selectDate1);
	
			cal2 = new dhtmlxCalendarObject('date', false, {isYearEditable: true});
			cal2.setYearsRange(2000, 2050);
			cal2.setPosition(20,-82);
			cal2.draw();
			// cal2.setOnClickHandler(selectDate2);
	
			document.getElementById('date').onfocus = function() { if (cal2.isVisible()) cal2.hide(); }
	
			document.body.onclick = function(){calendarHide("cal1,cal2","D");};
		}
	
		function selectDate1(date)
		{
			document.getElementById('date').value = cal1.getFormatedDate(null,date);
			dateFrom = new Date(date);
			dateTo = null;
			cal2.setSensitive(dateFrom, dateTo);
			cal1.hide();
			return true;
		}
	
	/////////////////////달력////////////////////////////////////////////////

		
		//저장
		function fnc_submit(f) {
		
			if (!fnc_validate(f)) {
				return false;
			}
			
			if (!confirm("<s:text name="alert.message.questionApply" />")) {
				return false;
			}
			
			f.action = "saveHolidaysReg_p.action";
		}
		
		//미입력 체크
		function fnc_validate(f) {

			if (document.getElementById("date").value == "" ) {
				alert("<s:text name="alert.message.requiedDate" />");
				f.type.focus();
				return false;
			}

			if (f.type == null || f.type.value == "" ) {
				alert("<s:text name="alert.message.requiedHoliday" />");
				f.type.focus();
				return false;
			}

			if (f.etc == null || f.etc.value == "" ) {
				alert("<s:text name="alert.message.emptyEtc" />");
				f.etc.focus();
				return false;
			}
			var cnt=0;
			for(var i=0; i<f.etc.value.length; i++){
               if(f.etc.value.charAt(i)== " "){
                     cnt++;
               }
			}
			if(f.etc.value.length == cnt){
               alert("명칭에 공백을 허용하지 않습니다.");
               f.etc.focus();
               return false;
			}
			return true;
			
		}
		
		//출근정보 저장시
		// ajax를 적용하여 opener의 죄회 데이터를 바로 적용함.
	    function fnc_apply_change() {
			
	        var rtn_msg = "<s:property value='msg' />";
	        
	        if (rtn_msg == "OK") {
		        alert("<s:text name="alert.message.applied" />");
		        window.close();
		        opener.fnc_dojo_publish();
		        return false;
	        }
	        
	    }
	
	</script>
	<!-- //-- --------------------J A V A S C R I P T-E N D-------------------- // -->
</head>
<body onload="fnc_apply_change();doOnLoad();">

        <s:form name="frm" id="frm" method="post" theme="simple" onsubmit="return fnc_submit(this)">
        	<s:hidden name="msg" 		/>				<!-- 저장 메시지 출력 -->
        	
        	<s:hidden name="crud_type"	/>
        	<s:hidden name="seq" />
			<div id="popup_350se_top" ></div>
		    <div id="popup_350se_bg">
		    <div id="popup_325se_box">
				<ul>
                    <li class="txt">일자</li>
			        <li><input type="text" size="12" maxlength="10" name="date" id="date" value="<s:property value="date" />" style="height:20;background-image:url('images/calendar/calendar.gif');background-repeat:no-repeat;background-position:right 2px;cursor:hand" /></li>
			    </ul>
			    <ul>
			        <li class="txt">유형</td>
			        <li><s:select 			name="type" id="type" list="list" listKey="cd" listValue="cd_nm" cssClass="combobox100se"></s:select> </li>
			    </ul>
			    <ul>
			        <li class="txt">명칭</li>
			        <li><s:textfield 		name="etc" id="etc" 	maxlength="15" cssClass="input_100se" /></li>
			    </ul>
			    
			    <div id="popup_btn"><s:submit type="image" src="/images/btn_save.gif" value="저장" /></div>
			   </div>
	    </div>
	    <br/><br/><br/>
	    <!---------------Bottom : STR----------->
		<div id="popup_350se_bottom"><img src="/images/pop_btn_close.gif" onclick="window.close();" style="cursor: pointer;"/></div>
		<!---------------Bottom : END----------->
        </s:form>
</body>
</html>